#include "FriendlyShip.h"
#include "Render.h"
#include "Definitions.h"

FriendlyShip::FriendlyShip()
{
	type		= FRIENDLYSHIP;
	docked		= false;
	numMissles	= MAX_MISSLES;

	//Set the position of the sprite info
	spriteInfo.pos = XY(SCREEN_HEIGHT - (SCREEN_HEIGHT / 5), SCREEN_WIDTH / 8);
	//Set the orientation of the sprite info
	spriteInfo.orientation = 0;
	//Set the color of the sprite info
	spriteInfo.color = WHITE;
	//Set the scale of the sprite info
	spriteInfo.scale = 1;
	//Load long range scan texture and set the referance number
	spriteInfo.reference = Render::getInstance()->LoadTexture("Friendly Ship.png", SQUARE_SIZE, SQUARE_SIZE);
}

void FriendlyShip::Init()
{
	docked		= false;
	numMissles	= MAX_MISSLES;

	//Initialize the total energy for the ship
	//totEnergy.Init(XY(50, 50), GREEN, MAX_ENERGY, MAX_ENERGY);
	//Initialize the shield energy for the ship
	//Shields.Init(XY(50, 50), BLUE, MAX_ENERGY, 0);
	//Initialize the energy weapon meter for the ship
	//EnergyWeapon.Init(XY(50, 50), RED, MAX_ENERGY, 0);
}

void FriendlyShip::Move(XY newPosition)
{
	//Set the friendly ship sprite's position to the sector that was chosen using the XY of that sector
	spriteInfo.pos = newPosition;
}

bool FriendlyShip::FireMissle()
{
	//If the number of current missles is zero
	if(numMissles <= 0)
	{
		//Than a missle can not be fired
		return false;
	}
	else
	{
		//Else the missle can be fired and the current missles need to be appropriately incremented (in this case decremented)
		numMissles--;

		return true;
	}
}

void FriendlyShip::Dock()
{
	//Set the docked variable accordingly
	docked = true;

	//Set the ships energy appropriately
	Shields.SetEnergy(0);
	totEnergy.SetEnergy(MAX_ENERGY);

	//Set the ships missles appropriately
	numMissles = MAX_MISSLES;
}

void FriendlyShip::UnDock()
{
	//Set the docked variable accordingly
	docked = false;
}

void FriendlyShip::Draw()
{
	//Set the long range scan's sprite using the sprite info
	sprite.setData(spriteInfo);

	//Draw the energy meters (total energy, shields, and energy weapon)
	totEnergy.Draw();
	Shields.Draw();
	EnergyWeapon.Draw();

	//Add the sprite node to the draw list
	Render::getInstance()->AddToDrawList(&sprite);
}